package ru.common;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

public class StatementEmailFactory {

    private final List<String> additionalRecipients = new ArrayList<String>();

    public StatementEmailFactory(String recipients) {
        if (recipients != null) {
            for (String r : recipients.split(",")) {
                if (StringUtils.isNotBlank(r)) {
                    additionalRecipients.add(r.trim());
                }
            }
        }
    }

    public StatementEmail getEmail(String to, String subject, String body) {
        StatementEmail email = new StatementEmail(to, null, subject, body);
        for (String cc : additionalRecipients) {
            email.addCc(cc);
        }
        return email;
    }

}
